﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZFS.Library;
using ZFS.Library.Generator;
using ZFS.Library.Helper;

namespace ZFS.ServerLibrary
{
    partial class BaseService : IBaseService
    {
        /// <summary>
        /// 获取表OR视图
        /// </summary>
        /// <returns></returns>
        public byte[] GetUvs()
        {
            try
            {
                List<string> result = Factory.GetGeneratorManager().GetUvs();
                byte[] bytes = ZipTools.CompressionObject(new ServiceResponse() { Success = true, Results = result });
                return bytes;
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteLog("获取表OR视图", ex);
                return ZipTools.CompressionObject(new ServiceResponse() { Success = false, ErrorCode = "", Message = ex.Message });
            }
        }

        /// <summary>
        /// 获取表结构
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        public byte[] GetTableStatus(string tableName, string nameSpace, string desc)
        {
            try
            {
                string result = Factory.GetGeneratorManager().GetTableStructs(tableName, nameSpace, desc);
                byte[] bytes = ZipTools.CompressionObject(new ServiceResponse() { Success = true, Results = result });
                return bytes;
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteLog("获取表结构", ex);
                return ZipTools.CompressionObject(new ServiceResponse() { Success = false, ErrorCode = "", Message = ex.Message });
            }
        }
    }
}
